package com.mvvm.start.common.service

import android.app.Service
import android.content.Intent
import android.os.IBinder
import com.mvvm.start.common.utils.UpDateAppHelper

/**
 * @author lmy
 * @功能: 调用系统下载
 * @Creat 2/23/21 2:51 PM
 * @Compony 465008238@qq.com
 */
class DownloadService : Service() {
    override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {

        intent.getStringExtra("url")?.let {
            UpDateAppHelper.updateApp(
                it,
                intent.getBooleanExtra("isAutomatic", true),
                intent.getStringExtra("fileName")!!
                ,{

                },{
                    stopSelf()
                }) {
                stopSelf()
            }
        }
        return super.onStartCommand(intent, flags, startId)
    }

    override fun onBind(intent: Intent): IBinder? {
        return null
    }
}